﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="paringlihtv2_paring", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(Paringlihtv2Paring))]
    public class Paringlihtv2ParingSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IParinglihtv2Paring clazz;
        
        public Paringlihtv2ParingSerializer(IParinglihtv2Paring clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.Evnimi!=null) {
                Writer.WriteStartElement("evnimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Evnimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AriregistriKood!=null) {
                Writer.WriteStartElement("ariregistri_kood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.AriregistriKood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Evarv!=null) {
                Writer.WriteStartElement("evarv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Evarv))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="evnimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paringlihtv2_paring>evnimi");
                }
                clazz.Evnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("evnimi")).Value;
            }
            if (Reader.LocalName=="ariregistri_kood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paringlihtv2_paring>ariregistri_kood");
                }
                clazz.AriregistriKood = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("ariregistri_kood")).Value;
            }
            if (Reader.LocalName=="evarv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paringlihtv2_paring>evarv");
                }
                clazz.Evarv = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("evarv")).Value;
            }
        }
    }
}
